<?php
/**
 * 入住信息同步
 * User: allen_ios
 * Date: 16/11/24
 * Time: 上午11:53
 */

namespace Task\App\Doorbjhq;
use Task\Core\Base;


class SyncDoorbjhqChangeRoom extends Base
{
    protected $mysql;

    public function __construct()
    {
        parent::__construct();
        $this->mysql = $this->selectDB('mysql');
    }


    public function getChangeList($account_id)
    {
        $sql = "select user_id,user_name,number,room_sex,building_id from gc_apartment_info where account_id = ".$account_id;
        $result = $this->mysql->query($sql)->fetchAll(\PDO::FETCH_ASSOC);
//        $doorctrlBjhqApi =new Service('Doorctrlbjhq/DoorctrlBjhqApi');
        $doorctrlBjhqApi = new DoorctrlBjhqApi();

        $functionName = 'AddUpdateUserEx';
        foreach($result as $k=>$v) {
            $params = array(
                'user' => array(
                    'userName' => $v['user_name'],
                    'sex' => $v['room_sex'],
                    'userNum' => $v['number'],
                    'outID' => $v['user_id'],
                    'outDepartID' => $v['building_id'],
                    'idCard' => '1',
                    'workType' => '01',
                    'headship' => '1',
                    'QRCode' => '1',
                    'photo' => '1')
            );
            $user_ms = json_encode($params);

            $aa = $doorctrlBjhqApi :: callApi($functionName, $params);

            cdump(json_encode($aa).$v['user_name']);
        }

    }

}